package com.elitesland.system.entity;

import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * <pre>发号器规则明细</pre>
 *
 * @author mir
 * @date 2020-10-10
 **/

@Entity
@Table(name = "sys_number_ruledtl")
@org.hibernate.annotations.Table(appliesTo = "sys_number_ruledtl", comment = "发号器规则明细")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "发号器规则明细", description = "发号器规则明细")
public class SysNumberRuleDtlDO extends BaseModel implements Serializable {
    private static final long serialVersionUID = 2847171578260093086L;

    @ApiModelProperty(value = "发号器规则ID")
    @Comment("发号器规则ID")
    @Column()
    Long ruleId;
    
    @ApiModelProperty(value = "排序号")
    @Comment("排序号")
    @Column()
    Integer seq;
    
    @ApiModelProperty(value = "取号类型：sys:numbertype, fs:固定字符串；dp：格式化日期；nn：自增序号")
    @Comment("取号类型：sys:numbertype")
    @Column()
    String numberType;  
    
    @ApiModelProperty(value = "取号模式，根据取号类型填写对应的固定字符串、日期格式化字符串、自增序号码")
    @Comment("取号模式，根据取号类型填写对应的固定字符串、日期格式化字符串、自增序号码")
    @Column()
    String numberPattern;

    @ApiModelProperty(value = "自增序号宽度，默认左补零")
    @Comment("自增序号宽度，默认左补零")
    @Column()
    Integer nnLen;
    
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof SysNumberRuleDtlDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SysNumberRuleDtlDO entity = (SysNumberRuleDtlDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}